package com.wx.nchu_mall.web;

import com.github.pagehelper.PageInfo;
import com.wx.nchu_mall.model.PageCondition;
import com.wx.nchu_mall.model.ReturnGoods;
import com.wx.nchu_mall.service.ReturnGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ReturnGoodsController {
    @Autowired
    protected ReturnGoodsService returnGoodsService;

    @PostMapping("/api/returngoods/findReturnGoodsList")   //按照分页查询所有的商品分类
    public PageInfo<ReturnGoods> findViewCommgory(@RequestBody PageCondition<ReturnGoods> condition){
        return returnGoodsService.page(condition);
    }

    @PostMapping("/api/returngoods/updateReturnGoods")
    public String update(@RequestBody ReturnGoods returnGoods){
        try{
            returnGoodsService.update(returnGoods);
            return "success";
        }catch (Exception e){
            return "fail";
        }
    }

    @PostMapping("/api/returngoods/deleteById")
    public String daleteById(@RequestBody ReturnGoods returnGoods){
        try{
            returnGoodsService.deleteById(returnGoods);
            return "success";
        }catch (Exception e){
            return "fail";
        }
    }

    @PostMapping("/api/returngoods/addReturnGoods")
    public String insert(@RequestBody ReturnGoods returnGoods){
        returnGoodsService.insert(returnGoods);
        return "success";
    }

    @PostMapping("/api/returngoods/findlist")
    public List<ReturnGoods> findList(@RequestBody ReturnGoods returnGoods){
        return returnGoodsService.findList(returnGoods);
    }


}
